package com.hqyj.javaGraduation.hotel.controller;

import com.hqyj.javaGraduation.hotel.pojo.UtMenuInfo;
import com.hqyj.javaGraduation.hotel.service.UtMenuInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;

@RestController
@RequestMapping("/api")
public class UtMenuInfoController {

    @Autowired
    UtMenuInfoService utMenuInfoService;

    /**
     * 127.0.0.1:8080/api/utMenuInfo    ---   get
     */
    // 客户购物车信息
    @GetMapping(value = "allUtMenuInfo")
    public HashMap<String, Object> queryAllMenuInfo(UtMenuInfo utMenuInfo){
        return utMenuInfoService.queryAllMenuInfo(utMenuInfo);
    }

    /**
     * 127.0.0.1:8080/api/utMenuInfo   ---   put
     * {"userId":1,"tableId":4,"menuId":1,"menuName":"盖饭","menuCost":10,"menuPrice":20}
     */
    //客户点菜
    @PutMapping(value = "utMenuInfo",consumes = "application/json")
    public HashMap<String, Object> insertMenuByUserId(@RequestBody UtMenuInfo utMenuInfo){
        return utMenuInfoService.insertMenuByUserId(utMenuInfo);
    }

    // 客户加菜
    @PostMapping(value = "addUtMenuInfo",consumes = "application/json")
    public int addMenuByUtMenuInfo(@RequestBody UtMenuInfo utMenuInfo){
        return utMenuInfoService.addMenuByUtMenuInfo(utMenuInfo);
    }

    // 客户减少菜品订购数量
    @GetMapping(value = "deleteUtMenuInfo",consumes = "application/json")
    public void deleteMenuByUtMenuInfo(@RequestBody UtMenuInfo utMenuInfo){
        utMenuInfoService.deleteMenuByUtMenuInfo(utMenuInfo);
    }

    /**
     * 127.0.0.1:8080/api/utMenuInfos   ---   get
     * {"page":1,"row":5}
     */
    // 给厨房打印订单
    @GetMapping(value = "/utMenuInfos",consumes = "application/json")
    public HashMap<String, Object> queryAllUtMenuInfo(@RequestBody UtMenuInfo utMenuInfo){
        return utMenuInfoService.queryAllUtMenuInfo(utMenuInfo);
    }

    // 修改支付状态
    @PostMapping(value = "/updateUtMenuInfo",consumes = "application/json")
    public int updateUtMenuInfoState(@RequestBody UtMenuInfo utMenuInfo){
        return utMenuInfoService.updateUtMenuInfoState(utMenuInfo);
    }
}
